<!--购物车组件-->
<template>
  <div class="headerCart">
    <a href="javascript:;" @click.prevent="handleCart">
      <span>购物车{{ cartItemsCount }}</span>
    </a>
  </div>
</template>
<script>
import { mapGetters } from "vuex";

export default {
  name: "HeaderCart",
  methods: {
    handleCart() {
      // 购物车页切换
      this.$router.push("/cart");
    },
  },
  computed: {
    // ...mapGetters("cart", {
    //   cartItemsCount: "itemsCount",
    // }),
    ...mapGetters({
      cartItemsCount: "cart/itemsCount",
    }),
  },
};
</script>

<style>
.headerCart {
  width: 20%;
  height: 26px;
  color: white;
  text-align: center;
  float: right;
}

.headerCart span {
  display: block;
  height: 34px;
  line-height: 34px;
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
}
</style>
